# 导包
from tools.db import chaxun
# 定义类

base_url ="http://ihrm-test.itheima.net/"


class login_Api():
    # 初始化
    def __init__(self):
        self.url_login = base_url+"api/sys/login"

    @staticmethod
    def build_data():
        sql = "select * from t_ihrm_test"
        db_data = []
        test_data = chaxun.chaxunsql(sql)


        for case_data in test_data:
            mobile = case_data[2]
            password = case_data[3]
            success = case_data[4]
            code = case_data[5]
            message = case_data[6]
            xycode= case_data[7]
            if success == "False":
                success = False
            else:
                success = True
            db_data.append((mobile,password,success,code,message,xycode))
        return db_data


    # 登录

    def login(self,sission,mobile,password):
        data = {
            "mobile":mobile,
            "password":password
        }

        response = sission.post(url=self.url_login,json=data)
        return  response
